package com.zhs.gccs.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hjq.shape.view.ShapeTextView;
import com.zhs.gccs.R;
import com.zhs.gccs.vo.AdminTaskBean;

/**
 * Created by chengzf on 2024/7/20.
 */
public class AdminGccsTaskAdapter extends BaseQuickAdapter<AdminTaskBean, BaseViewHolder>{

    public AdminGccsTaskAdapter() {
        super(R.layout.item_admin_gccs_task_view);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, AdminTaskBean bean) {

        holder.setText(R.id.tv_num, holder.getBindingAdapterPosition() + 1 +"");
        holder.setText(R.id.tv_task_time, bean.getPdate());
        holder.setGone(R.id.tv_task_people, bean.getUserExecName() != null && !bean.getUserExecName().isEmpty());
        holder.setText(R.id.tv_task_people, bean.getUserExecName());
        holder.setText(R.id.tv_task_name, bean.getXmmc());
        //  "state": "11",		//任务状态(null-未下发 ，10-已下发(未开始)，11-已下发(抽检中)，20-已完成)
        ShapeTextView state = holder.getView(R.id.tv_task_state);
        if (bean.getState() == null || bean.getState().isEmpty()){
            state.setText("未下发");
            state.getShapeDrawableBuilder()
                    .setSolidColor(0xFF416FFC)
                    .intoBackground();
        }else {
            if ("20" == bean.getState()){
                state.setText("已完成");
                state.getShapeDrawableBuilder()
                        .setSolidColor(0xFFFF8600)
                        .intoBackground();

            }else {
                state.setText("已下发");
                state.getShapeDrawableBuilder()
                        .setSolidColor(0xFF416FFC)
                        .intoBackground();
            }
        }
    }
}
